/**
*
* 系统所有的菜单函数
*
*/

/**
 * 问卷设计菜单
 */
function showSurveyStatMgmt() {
	var popupMenu = Ext.menu.MenuMgr.get("popupMenu");
	if(popupMenu) {
		popupMenu.removeAll();
		popupMenu = null;
	}
	popupMenu = new Ext.menu.Menu({id: 'popupMenu'});
	popupMenu.addMenuItem({text: '答题页面', handler: function(){
		window.open("aq/answerQuestions.do?spk=1");
	}});
	
	var systemMgmtMenu = Ext.fly("showSurveyStatMgmt");
    var position = [systemMgmtMenu.getLeft(), systemMgmtMenu.getBottom()];
    popupMenu.showAt(position);
}

/**
 * 显示文档管理界面
 * @param type
 * @return
 */
function showDocumentMgmtPanel() {
	var taskPanel = Ext.getCmp("taskPanel");
	var panel = taskPanel.findById("documentQueryMgmtPanel");
	if(!panel) {
		panel = new DocumentQueryMgmtPanel({ismanager: true});
		taskPanel.add(panel);
		panel.doLayout(); 
		taskPanel.setActiveTab(panel);
	}
	taskPanel.setActiveTab(panel);
}

/**
 * 显示系统管理子菜单
 */
function showSystemMgmtMenu() {
	var popupMenu = Ext.menu.MenuMgr.get("popupMenu");
	if(popupMenu) {
		popupMenu.removeAll();
		popupMenu = null;
	}
	popupMenu = new Ext.menu.Menu({id: 'popupMenu'});
	popupMenu.addMenuItem({text: '组织机构管理', handler: showOrgMgmt});
	popupMenu.addMenuItem({text: '用户管理', handler: showUsersMgmt});
	popupMenu.addMenuItem({text: '系统参数配置', handler: showParamsMgmt});
	
	var systemMgmtMenu = Ext.fly("systemMgmtMenu");
    var position = [systemMgmtMenu.getLeft(), systemMgmtMenu.getBottom()];
    popupMenu.showAt(position);
}

/**
* 显示组织机构管理
* */
function showOrgMgmt() {
	var taskPanel = Ext.getCmp("taskPanel");
	var orgMgmt = taskPanel.findById("orgMgmtPanel");
	if(!orgMgmt) {
		orgMgmt = new OrgMgmtPanel();
		taskPanel.add(orgMgmt);
	}
	taskPanel.setActiveTab(orgMgmt);
}

/**
 * 显示用户管理
 * */
function showUsersMgmt() {
	alert("正在开发中...");
//	var taskPanel = Ext.getCmp("taskPanel");
//	var usersMgmt = taskPanel.findById("userMgmtPanel");
//	if(!usersMgmt) {
//		usersMgmt = new UserMgmtGridPanel();
//		taskPanel.add(usersMgmt);
//	}
//	taskPanel.setActiveTab(usersMgmt);
}

/**
 * 显示系统参数管理
 * */
function showParamsMgmt() {
	alert("正在开发中...");
//	var teskPanel = Ext.getCmp("taskPanel");
//	var paramsMgmt = taskPanel.findById("paramsMgmtPanel");
//	if(!paramsMgmt) {
//		paramsMgmt = new ParamsMgmtPanel();
//		taskPanel.add(paramsMgmt);
//	}
//	taskPanel.setActiveTab(paramsMgmt);
}

/**
 * 统计分析
 * @return
 */
function showSurveyStatDesignMgmt() {
	var taskPanel = Ext.getCmp("taskPanel");
	var panel = taskPanel.findById("surveyStatMgmtPanel");
	if(!panel) {
		panel = new SurveyStatMgmtPanel();
		taskPanel.add(panel);
		panel.doLayout(); 
		taskPanel.setActiveTab(panel);
	}
	taskPanel.setActiveTab(panel);
}

/**
 * 获取随机数
 * */
function getRandomNumber() {
	return new Date().getMilliseconds();
}